import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 食物过敏信息 */
export interface RecipeFoodAllergy {
  id: number // 编号
  classId?: number // 班级ID
  studentId?: number // 学生ID
  foodTypeId: string // 食物分类编号
  foodId: string // 食物编号
  foodName: string // 食物名称
  allergyLevel: number //过敏程度
  sort?: number // 排序
  status?: number // 状态
}

// 食物过敏 API
export const RecipeFoodAllergyApi = {
  // 查询食物过敏分页
  getRecipeFoodAllergyPage: async (params: any) => {
    return await request.get({ url: `/school/recipe-food-allergy/page`, params })
  },

  // 查询食物过敏详情
  getRecipeFoodAllergy: async (id: number) => {
    return await request.get({ url: `/school/recipe-food-allergy/get?id=` + id })
  },

  // 新增食物过敏
  createRecipeFoodAllergy: async (data: RecipeFoodAllergy) => {
    return await request.post({ url: `/school/recipe-food-allergy/create`, data })
  },

  // 修改食物过敏
  updateRecipeFoodAllergy: async (data: RecipeFoodAllergy) => {
    return await request.put({ url: `/school/recipe-food-allergy/update`, data })
  },

  // 删除食物过敏
  deleteRecipeFoodAllergy: async (id: number) => {
    return await request.delete({ url: `/school/recipe-food-allergy/delete?id=` + id })
  },

  /** 批量删除食物过敏 */
  deleteRecipeFoodAllergyList: async (ids: number[]) => {
    return await request.delete({
      url: `/school/recipe-food-allergy/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出食物过敏 Excel
  exportRecipeFoodAllergy: async (params) => {
    return await request.download({ url: `/school/recipe-food-allergy/export-excel`, params })
  }
}
